package com.java.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.java.dao.ActivityLawDao;
import com.java.domain.ActivityLaw;
import com.java.domain.event.ActivityLawEvent;
import com.java.service.LawService;
import com.java.util.resp.BaseRespone;
import com.java.util.resp.TableRespone;

@Service
public class LawServiceImpl implements LawService {

	@Resource
	ActivityLawDao lawDao;

	@Override
	public TableRespone getList(int page, int size) {
		Map<String, Object> params = new HashMap<String, Object>();
		List<ActivityLawEvent> list = lawDao.selectAll(params, page, size);
		long total = lawDao.selectAllCount(params);
		return new TableRespone(list, total);
	}

	@Override
	public ActivityLawEvent getOneByCode(String lawCode) {
		ActivityLawEvent info = lawDao.selectByInfo(new ActivityLaw().setLawCode(lawCode));
		return info;
	}

	@Override
	public BaseRespone updateLaw(String lawId, String lawRemark, String lawContent) {
		ActivityLawEvent info = lawDao.selectByKey(lawId);
		info.setLawRemark(lawRemark);
		info.setLawContent(lawContent);
		info.setLawModify(new Date());
		int row = lawDao.updateSelective(info);
		return BaseRespone.result(row, "Modify Success");
	}
}
